#include "RGBFilter.h"
#include <cv.h>

using namespace cv;

void RGBFilter::process(const Mat & src, Mat & dst){
	bool copiar = true;

	Mat tmp;
	//Cambio a 8 Bits enteros por canal
	if (src.depth() != CV_8U){
		src.convertTo(tmp, CV_8U, 1, 0);
		copiar = false;
	}

	int conversion = 0;
	//Si es escala de grises
	if (src.channels() == 1){
		conversion = CV_GRAY2RGB;
	} //Si es RGBA
	else if (src.channels() == 4){
		conversion = CV_RGBA2RGB;
	}

	if (copiar && conversion)
		cvtColor(src, dst, conversion, 3);
	else if (conversion)
		cvtColor(tmp, dst, conversion, 3);
	else
		dst = src.clone();
}
